<?php
/*
Template Name: Ings
*/
?>
<?php get_header(); //这个page template的页面结构请参照当前所使用的主题来修改 ?>
<div class="contentarea">
	<div class="wide">
		<?php include (TEMPLATEPATH . '/ing.php'); ?>
		<div class="postinfo">
			<h2>iHao Ings Lists</h2>
		</div>
			<ol>
				<?php
					$ingid = 'ihao'; //你的饭否id
					$noname = true; //是否去掉用户名,为'true'时请正确填写下面的$ingname值。不去的话改为'false',$ingname的值可不用管
					$ingname = 'ihao'; //你的饭否用户名
					$ingnum = 20; //输出饭否消息的条数,1为输出最新的一条消息,最多20条
					require_once (ABSPATH . WPINC . '/rss.php');
					$feed_url = 'http://api.fanfou.com/statuses/user_timeline/'.$ingid.'.rss';
					$rss = @fetch_rss($feed_url);	
					if ( isset($rss->items) && 0 < count($rss->items) ) { 
						$rss->items = array_slice($rss->items, 0, $ingnum);
						foreach ($rss->items as $item ) {
							$ihao_ing = ($noname)?preg_replace( '|'.$ingname.'：(.+)?|s', '$1', $item['title']):$item['title'];
				?> 
							<li><a href="<?php echo $item['link']; ?>"><?php echo $ihao_ing; ?></a> &raquo; <?php printf(__('%s ago'), human_time_diff(strtotime($item['pubdate'], time() ) ) ); ?></li>
				<?php } } ?>
			</ol>
	</div>
	<?php get_sidebar(); ?>
</div>
<?php get_footer(); ?>